💯 solving-algo | January 15, 2021
https://www.acmicpc.net/problem/11654
import sys
print(ord(sys.stdin.readline().strip()))
https://www.acmicpc.net/problem/11720
import sys
N = int(sys.stdin.readline())
cal = sys.stdin.readline()
ans = 0
for i in range(N):
ans += int(cal[i])
print(ans)
https://www.acmicpc.net/problem/10809
import sys
s = sys.stdin.readline().rstrip()
alphabet = list(range(97, 123))
for x in alphabet:
print(s.find(chr(x)))
https://www.acmicpc.net/problem/2675
import sys
n = int(sys.stdin.readline().strip())
for i in range(n):
tmp = ''
s = list(map(str, sys.stdin.readline().strip().split()))
for j in s[1]:
tmp += (j*int(s[0]))
print(tmp)
https://www.acmicpc.net/problem/1157
import sys
from collections import Counter
s = sys.stdin.readline().strip()
arr = []
for i in s.upper():
arr.append(i)
count = Counter(arr)
# print(count, count.most_common(1), count.most_common(2)[1])
try:
if count.most_common(1)[0][1] == count.most_common(2)[1][1]:
print("?")
else:
print(count.most_common(1)[0][0])
except:
print(count.most_common(1)[0][0])
https://www.acmicpc.net/problem/1152
import sys
s = sys.stdin.readline().rstrip().split()
print(len(s))
https://www.acmicpc.net/problem/2908
import sys
a, b = sys.stdin.readline().rstrip().split()
tmp = int(a[::-1])
tmp2 = int(b[::-1])
arr = [tmp, tmp2]
print(max(arr))
https://www.acmicpc.net/problem/5622
s = input().upper()
arr = ['ABC', 'DEF', 'GHI', 'JKL', 'MNO', 'PQRS', 'TUV', 'WXYZ']
cnt = 0
for i in range(len(s)):
for j in arr:
if(s[i] in j):
cnt += arr.index(j) + 3
print(cnt)
https://www.acmicpc.net/problem/2941
a = ['c=', 'c-', 'dz=', 'd-', 'lj', 'nj', 's=', 'z=']
b = input()
for i in a:
b = b.replace(i, 'a')
print(len(b))
https://www.acmicpc.net/problem/1316
# 내 풀이
# 처음에 나오는 단어들 pop해서 arr에 다 집어넣음
# 다른 단어가 최초로 들어왔을 때 set()으로 중복제거
# 그 이후에 들어오는 단어들이 arr에 있다면 그룹단어가 아님
# ex) "aabbcca" [a,a,b] => [a,b] => [a,b,b] => [a,b,c]
import sys
n = int(sys.stdin.readline().rstrip())
cnt = 0
for i in range(n):
arr = []
s = sys.stdin.readline().rstrip()
for j in range(len(s) - 1):
arr.append(s[j])
if arr[-1] != s[j+1]:
arr = list(set(arr))
if s[j+1] in arr:
break
else:
cnt += 1
print(cnt)
# 다른 사람 풀이
n = int(input())
group_word = 0
for _ in range(n):
word = input()
error = 0
for index in range(len(word)-1): # 인덱스 범위 생성 : 0부터 단어개수 -1까지
if word[index] != word[index+1]: # 연달은 두 문자가 다른 때,
new_word = word[index+1:] # 현재글자 이후 문자열을 새로운 단어로 생성
if new_word.count(word[index]) > 0: # 남은 문자열에서 현재글자가 있있다면
error += 1 # error에 1씩 증가.
if error == 0:
group_word += 1 # error가 0이면 그룹단어
print(group_word)